﻿namespace Moe.ECamel.Common.Entities
{
	using System;
	using System.ComponentModel;

	partial class Customer : IEditableObject
	{
		public string Username
		{
			get { return this.User.Username; }
		}
		public string FirstName
		{
			get { return this.User.FirstName; }
		}
		public string LastName
		{
			get { return this.User.LastName; }
		}

		public ECamelError Validate()
		{
			// Validate user:
			ECamelError userError = this.User.Validate();
			if (userError != null)
				return userError;

			return null;
		}

		#region IEditableObject Members

		private Customer _originalEntity = null;

		public void BeginEdit()
		{
			if (this._originalEntity == null)
			{
				// Initialize original
				this._originalEntity = new Customer();
				// Copy editable properties values:
				this._originalEntity._PaymentsBalance = this._PaymentsBalance;
			}
		}

		public void CancelEdit()
		{
			if (this._originalEntity != null)
			{
				// Restore properties:
				this._PaymentsBalance = this._originalEntity._PaymentsBalance;
				// Reset original values:
				this._originalEntity = null;
			}
		}

		public void EndEdit()
		{
			// Reset original values:
			this._originalEntity = null;
		}

		#endregion
	}
}